package com.jiot.common;

/**
 * @author liling
 * @date 2020/10/12 10:08
 * @description 系统错误码
 **/
public enum ErrorCode {

    /**
     * 常规异常 10-99
     **/
    PARAM_VALIDATE_ERROR(10, "参数验证错误"),
    PARAM_ERROR(11, "参数错误"),
    GET_SESSION_ERROR(12, "获取Session错误"),
    SYSTEM_ERROR(13, "系统错误"),
    FILE_NOT_EXISTS(14, "文件不存在"),
    LESS_CONFIG(15, "缺少配置项"),
    SECURITY_ERROR(16, "身份认证异常"),
    ATTACHMENT_UPLOAD_FAILED(36, "文件上传失败"),
    ATTACHMENT_TOO_LARGE(48, "上传文件过大[单个文件大小不得超过%s]"),
    REQUEST_ATTACHMENTS_TOO_LARGE(49, "总上传文件过大[总上传文件大小不得超过%s]"),
    TIME_FORMAT_ERROR(50, "时间格式错误"),
    INVALID_ORDER_BY_TYPE(51, "无效的排序类型"),
    ADD_IMG_ERROR(52, "添加图片失败"),
    MAX_SORT_ERROR(53, "已经是最后一条了，不能再进行降序操作"),
    MIN_SORT_ERROR(54, "已经是第一条了，不能再进行升序操作"),
    PROJECT_NAME_EXTEND(55, "数据已经存在，请检查后操作"),
    NO_FIND_MODEL(56, "没有找到模块数据"),
    NOT_CANT_DEL(57, "模块下有接口，不能删除模块"),
    FILE_NULL(58,"文件为空"),
    FIND_PRODUCT_ERROR(59,"查询产品失败"),
    PAGE_PARAM_NULL(60,"分页参数为空"),
    FIND_IMG_ERROR(61,"查询图片失败"),
    FIND_BANNER_LIST_ERROR(62,"查询banner列表数据"),
    /**业务异常，根据业务模块端口号开头定义 **/


    /**
     * 用户模块 错误代码 3开头
     **/
    USERNAME_NOT_EXIST(3001, "账号不存在"),
    USER_INFO_MISSING(3002, "用户信息缺失"),
    USER_PASSWORD_MISMATCH(3003, "密码错误"),
    ROLE_NOT_EXIST(3004, "角色不存在"),
    ADD_USER_ROLE_ERROR(3005, "新增用户角色关联失败"),
    ADD_USER_ERROR(3006, "新增用户失败"),
    USER_EXIST(3007, "用户已存在"),
    LOGOUT_FAILED(3008, "注销失败"),
    RESET_PASSWORD_EQUALS(3009, "新旧密码不能相同"),
    USER_NOT_EXIST(3010, "用户不存在"),
    RESET_PASSWORD_FAILED(3011, "重置密码失败"),
    OLD_PASSWORD_ERROR(3012, "旧密码错误"),
    SET_PASSWORD_FAILED(3013, "设置密码失败"),
    INVILID_USER_STATUS(3014, "无效的用户状态"),
    USER_UPDATE_INFO_FAILED(3015, "修改用户资料失败"),
    USERNAME_EXIST(3016, "用户名已存在"),
    USER_PHONE_EXIST(3017, "手机号已存在"),
    USER_UPDATE_PHONE_FAILED(3018, "修改用户手机号失败"),
    MINI_PROGRAM_AUTHORIZATION_FAILED(3019, "微信授权失败"),
    PERFECT_USER_INFO_FAILED(3020, "用户完善个人资料失败"),

    USER_OPERATION_FAILED_ERROR(3021, "操作失败"),

    USER_DISABLED_ERROR(3022, "该手机号已禁用"),
    USER_DISABLE(3023, "用户已禁用"),
    USER_INFO_EXCEPTION(3024, "用户信息异常"),
    USER_ROLE_INFO_EXCEPTION(3025, "用户角色信息异常"),
    AUTHORITY_INVALID(3026, "无访问权限"),
    INVALID_ROLE_NUM(3027, "无效的角色参数"),
    ROLE_AREA_NOT_MATCH(3028, "角色和区域不匹配"),
    NO_AUTHORITY_CREATE_THIS_ROLE(3029, "无权创建该等级用户"),
    AUTHORITY_INVALID_OPERATE(3030, "无权操作该数据"),
    DELETE_USER_FAILED(3031, "删除用户失败"),
    UPDATE_EXTEND_FAILED(3032, "更新拓展信息失败"),
    ADD_EXTEND_FAILED(3033, "新增拓展信息失败"),
    GET_UNIONID_FAILED(3034, "获取unionid失败"),

    /**
     * 设备模块 错误代码4开头
     **/
    REMOTE_CONTROL_IS_NOT_ACTIVATED(4000, "设备远程控制未启动"),
    DEVICE_ADD_ERROR(4001, "添加设备失败"),
    DEVICE_ADD_REPEAT_ERROR(4002, "设备唯一码存在，请勿重复添加！"),
    DEVICE_MOD_ERROR(4003, "修改设备失败"),
    DEVICE_DEL_ERROR(4004, "删除设备失败"),
    DEVICE_BIN_ERROR(4005, "绑定设备失败"),
    DEVICE_UNBUN_ERROR(4006, "绑定设备失败"),
    DEVICE_SET_ERROR(4007, "设置设备阈值失败"),
    DEVICE_NOT_EXIST(4008, "设备不存在"),
    OPEN_AND_CLOSE_ERROR(4009, "开合闸操作失败"),


    ADD_SCENE_FAILED(4010, "新增场景失败"),
    SCENE_INFO_MISSING(4011, "场景信息缺失"),
    ADD_PROJECT_FAILED(4012, "新增项目失败"),
    PROJECT_EXIST(4013, "项目名称重复"),
    PROJECT_NOT_EXIST(4014, "项目不存在"),
    UPDATE_PROJECT_FAILED(4015, "项目更新失败"),

    SCENE_INFO_EXIST(4016, "场景信息不存在"),
    SCENE_UPDATE_FAILED(4017, "修改场景信息失败"),
    SCENE_EXIST_ERROR(4018, "场景名称已存在"),
    PROJECT_INDUSTRY_UPDATE_FAILED(4019, "修改项目行业失败"),
    INDUSTRY_NOT_EXIST(4020, "行业信息不存在"),
    SCENE_BIND_DEVICE(4021, "场景已绑定设备，不能删除"),
    SCENE_REMOVE_FAILED(4022, "删除场景失败"),

    PRODUCT_ADD_ERROR(4030, "添加产品失败"),
    PRODUCT_DEL_ERROR(4031, "删除产品失败"),
    PRODUCT_MOD_ERROR(4032, "修改产品失败"),

    INFORMATION_ADD_ERROR(4040, "添加资讯失败"),
    INFORMATION_DEL_ERROR(4041, "删除资讯失败"),
    INFORMATION_MOD_ERROR(4042, "修改资讯失败"),
    INFORMATION_RELEASE_ERROR(4043, "操作失败"),

    ADD_DEFAULT_THRESHOLD_ERROR(4050, "添加默认阈值失败"),
    ADD_REPEATEDLY_DEFAULT_THRESHOLD_ERROR(4051, "该类型已存在"),
    SET_DEFAULT_THRESHOLD_ERROR(4052, "设置默认阈值失败"),
    FIND_DEFAULT_THRESHOLD_ERROR(4053, "查询默认阈值失败"),

    ADD_TIMING_TASK_ERROR(4060, "添加定时任务失败"),
    MODIFY_TIMING_TASK_ERROR(4061, "修改定时任务失败"),
    TIMING_TASK_OPERATION_FAILED_ERROR(4062, "定时任务操作失败"),
    ALARM_NOTICE_NOT_EXIST(4063, "暂无报警信息"),
    ALARM_DEVICE_NOT_EXIST(4064, "暂无设备报警"),
    UPDATE_ALARM_NOTICE_FAILED(4065, "更新报警信息状态失败"),

    ADD_DEVICE_TRIAL_DURATION_ERROR(4070, "添加设备试用时长失败"),
    MODIFY_DEVICE_TRIAL_DURATION_ERROR(4071, "修改设备试用时长失败"),
    DEL_DEVICE_TRIAL_DURATION_ERROR(4072, "删除设备试用时长失败"),
    DEVICE_TRIAL_DURATION_ERROR(4073, "该设备类型已存在设备试用时长，请直接修改"),
    DEVICE_OFFLINE(4074, "该设备已离线"),
    INVALID_TIME_TYPE(4074, "无效的时间类型"),

    ADD_HELP_CENTER_ERROR(4080, "添加帮助失败"),
    DEL_HELP_CENTER_ERROR(4081, "删除帮助失败"),
    MODIFY_HELP_CENTER_ERROR(4082, "修改帮助失败"),
    ASC_HELP_CENTER_ERROR(4083, "该数据已在第一位"),
    DESC_HELP_CENTER_ERROR(4084, "该数据已在最后一位"),
    INVALID_ALARM_INFO_STATUS(4085, "无效的报警信息状态类型"),
    INVALID_ALARM_TYPE(4086, "无效的报警类型"),
    WARNING_NOT_EXIST(4087, "暂无报警设备"),
    INSPECTION_NOTICE_ERROR(4088, "通知异常"),
    INSPECTION_FAILED(4089, "巡检出错"),
    ADD_FUNCTIONAL_REPORT_FAILED(4090, "新增报表失败"),
    REPORT_NOT_EXIST(4091, "暂无报表数据"),
    INVALID_DEVICE_STATUS(4092, "无效的设备状态"),
    DEL_DEVICE_ERROR(4093, "该设备已绑定用户，请解绑在删除"),
    PROJECT_DEVICE_EXIST(4094, "项目中已绑定设备，请先解绑"),
    SYNCHRONIZE_DEVICE_STATUS(4095, "正在同步设备状态"),
    DEVICE_NOT_BIND(4096, "设备已解除绑定"),
    THRESHOLD_KEY_NOT_EXIST(4097, "阈值key不存在"),
    DEFAULT_THRESHOLD_NOT_EXIST(4098, "默认阈值不存在"),
    SYNC_IOT_THRESHOLD_FAILED(4099, "同步iot阈值失败"),
    NO_DEVICE_OPERATE_AUTH(4100, "没有设备操作权限"),
    DEVICE_BOUND(4101, "设备已绑定"),
    DEVICE_UNTIE_FAILED(4102, "设备解绑失败"),
    DEVICE_ALREADY_UNTIE(4013, "设备已解除绑定"),
    BATCH_SET_MANAGER_FAILED(4014, "批量设置管理区域失败"),
    ALARM_NOTICE_HAVE_READ_FAILED(4015, "消息已读失败"),
    /**
     * order服务 错误代码 5开头
     **/
    WORK_ORDER_ADD_FAILED(5001, "新增工单失败"),
    WORK_ORDER_DEVICE_ADD_FAILED(5002, "新增工单设备失败"),
    WORK_ORDER_NOT_EXIST(5003, "工单不存在"),
    WORK_ORDER_FEE_ADD_FAILED(5004, "工单费用新增失败"),
    PROJECT_WORK_WORD_EXIST(5005, "工单已存在,项目"),
    NEW_INSTALL_ORDER_EXIST(5006, "新装工单已存在"),

    ADD_ORDER_PRICE_ERROR(5010, "添加订单价格失败"),

    /**
     * 公共服务 错误代码 6开头
     **/
    SEND_MESSAGE_FAILED(6001, "短信验证码发送失败"),
    VALID_CODE_EXPIRE(6002, "验证码已过期"),
    VALID_CODE_ERROR(6003, "验证码错误"),
    AREA_NOT_EXIST(6004, "区域信息不存在"),
    GET_AREA_INFO_FAILED(6005, "获取区域信息失败"),
    ADMIN_AREA_INFO_ERROR(6007,"管理员区域信息错误"),

    /**
     * iot服务 错误代码 7开头
     **/
    ADD_DEVICE_LOG_FAILED(7001, "插入采集数据失败"),


    /**
     * job服务 错误代码 9开头
     **/
    CRON_INVALID(9001, "cron表达式无效"),
    JOB_ADD_FAILED(9002, "新增jobInfo失败"),
    DEVICE_CRON_EXIST(9003, "该设备已存在定时任务"),

    /**
     * api接口模块 10开头
     */
    ADD_API_ERROR(10001, "添加api接口失败"),
    DEL_API_ERROR(10002, "删除接口失败"),
    EDIT_API_ERROR(1003, "修改接口失败"),
    ADD_API_REQUEST_ERROR(10004, "添加接口请求参数错误"),
    ADD_API_RESPONSE_ERROR(10005, "添加接口返回参数错误"),
    EDIT_API_PARAM_ERROR(10006, "修改接口参数错误"),
    EDIT_API_REQUEST_ERROR(10007, "修改接口请求参数错误"),
    EDIT_API_RESPONSE_ERROR(10008, "修改接口返回参数失败"),
    FIND_API_ERROR_INFO_ERROR(10009, "查询接口错误码错误"),
    FIND_API_REQUEST_ERROR(10010, "查询接口请求参数错误"),
    FIND_API_RESPONSE_ERROR(10011, "查询接口返回参数错误"),
    ADD_API_ERROR_INFO_ERROR(10012, "添加接口错误码错误"),
    EDIT_API_ERROR_INFO_ERROR(10013, "修改接口错误码错误"),
    DEL_API_ERROR_INFO_ERROR(10014, "删除接口错误码错误"),

    /**
     * 公共模块 11开头
     */
    ADD_PROBLEM_ERROR(11001,"添加常见问题失败"),
    EDIT_PROBLEM_ERROR(11002,"修改常见问题失败"),
    DEL_PROBLEM_ERROR(11003,"删除常见问题失败"),
    FIND_PROBLEM_LIST_ERROR(11004,"查找常见问题列表失败"),
    DEL_NEW_USER_IMG_ERROR(11005,"删除新手指导图片失败"),
    DEL_NEW_USER_ERROR(11006,"删除新手指导失败"),
    FIND_MODEL_ERROR(11007,"查询模块失败"),
    FIND_USER_MESSAGE_ERROR(11008,"查询用户留言失败"),
    DEL_USER_MESSAGE_ERROR(11009,"删除用户留言失败"),
    EDIT_USER_MESSAGE_ERROR(11010,"修改用户留言失败"),
    ADD_USER_MESSAGE_ERROR(11010,"添加用户留言失败")

    ;

    /**
     * 错误码
     **/
    private Integer code;
    /**
     * 异常信息
     **/
    private String message;

    ErrorCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public String getFormatMessage() {
        return String.format("【%d】 %s", code, message);
    }
}
